<template>
  <view class="container">
    <view class="card">
      <view class="title">登录</view>

      <input class="input" placeholder="请输入用户名" v-model="username" />
      <input class="input" placeholder="请输入密码" v-model="password" password="true" />

      <button class="btn" @click="login">登录</button>

      <view class="footer">
        <text class="hint">没有账号？</text>
        <navigator url="/pages/register/register">
          <text class="link">去注册</text>
        </navigator>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: "LoginPage",
  data() {
    return {
      username: "",
      password: ""
    };
  },
  methods: {
    login() {
      if (!this.username || !this.password) {
        uni.showToast({ title: "请输入用户名和密码", icon: "none" });
        return;
      }
      uni.showToast({ title: "登录成功", icon: "success" });
      uni.switchTab({ url: "/pages/tabBar/tabcompage/tabcompage" });
    }
  }
};
</script>

<style scoped>
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #f5f5f5;
}

.card {
  width: 80%;
  padding: 40rpx 30rpx;
  background: #fff;
  border-radius: 12rpx;
  box-shadow: 0 10rpx 40rpx rgba(0, 0, 0, 0.12);
  text-align: center;
}

.title {
  font-size: 40rpx;
  font-weight: 600;
  margin-bottom: 30rpx;
  color: #333;
}

.input {
  width: 100%;
  height: 70rpx;
  margin-bottom: 22rpx;
  padding: 0 20rpx;
  border: 1rpx solid #ddd;
  border-radius: 8rpx;
  font-size: 28rpx;
  text-align: left;
  background: #fff;
  box-sizing: border-box;
}

.btn {
  width: 100%;
  height: 70rpx;
  line-height: 70rpx;
  background: #007aff;
  color: #fff;
  font-size: 30rpx;
  border-radius: 8rpx;
  margin-top: 10rpx;
}

.footer {
  margin-top: 25rpx;
  display: flex;
  justify-content: center;
  font-size: 24rpx;
}

.hint {
  color: #666;
}

.link {
  margin-left: 8rpx;
  color: #007aff;
}
</style>
